package com.zecan.blog.vo.message;

import com.zecan.blog.entity.Message;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName MessageVo
 * @Description
 * @date 2022/11/23 10:41
 * @Version 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class MessageVo {

    Integer id;
    String username;
    String avatar;
    String messageContent;
    Integer timer; // 弹幕运行的时间保存起来
    String messageCreateTime; // 创建时间

    Integer messageCount;

    public static MessageVo buildMessageVo(Message message) {
        MessageVo messageVo = new MessageVo();
        messageVo.avatar = message.getMessageAvatar();
        messageVo.messageContent = message.getMessageContent();
        messageVo.timer = message.getMessageTimer();
        messageVo.username= message.getMessageUsername();
        messageVo.id = message.getMessageId();
        messageVo.messageCreateTime = message.getMessageCreateTime();
        messageVo.messageCount = message.getMessageCount();
        return  messageVo;
    }
}
